/*
    6. Write a program in C to find the content of the file and number of lines in a Text File. 
    Test Data :
    Input the file name to be opened : test.txt
    Expected Output :

    The content of the file test.txt  are :                                                                      
    test line 1                                                                                                  
    test line 2                                                                                                  
    test line 3                                                                                                  
    test line 4                                                                                                  
    The lines in the file are : 4
*/

#include <stdio.h>

int main(void)
{
    FILE *fp;
    int lines = 0;
    char filename[64];
    char ch;
    printf("Input the file name to be opened : ");
    scanf("%s", filename);
    fp = fopen(filename, "r");
    printf("The content of the file %s are : \n", filename);
    while((ch = fgetc(fp)) != EOF){
        putc(ch, stdout);
        if(ch == '\n'){
            lines++;
        }
    }
    printf("The lines of file %s are : %d", filename, lines);   

    return 0;
}